<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <script src="../node_modules/react/umd/react.development.js"></script>
    <script src="../node_modules/react-dom/umd/react-dom.development.js"></script>
    <script src="../node_modules/babel-standalone/babel.min.js"></script>
    <title>ref回调函数</title>
</head>

<body>
    <h1>ref回调函数</h1>
    <ol>
        <li></li>
    </ol>
    <hr />
    <div id="demoReact"></div>
</body>
<script src="../../node_modules/babel-standalone/babel.min.js"></script>
<script src="../../node_modules/react/umd/react.development.js"></script>
<script src="../../node_modules/react-dom/umd/react-dom.development.js"></script>
<script type="text/babel">

    function MyCom() {

        let textinput = null;


        let fun = () => {
            console.log(textinput.value);
            
        }

        
        return (
            <div>
                <div>我是一个类组件</div>
                <input type="text" ref={(inputObj) => { textinput = inputObj }} replaceholder="请输入" onInput={fun}/>
            </div>
        )
        
    }

    // 创建根节点
    let root = ReactDOM.createRoot(document.getElementById("demoReact"));

    // 渲染组件
    root.render(<MyCom />);
</script>

</html>